/*
 * ./lib/socket.h
 * Copyright (C) 2009 Lameire Alexis
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef SOCKET_H
#define SOCKET_H
#if defined (WIN32)
	#include <winsock2.h>
	typedef int socklen_t;
#elif defined (linux)
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <arpa/inet.h>
	#include <netdb.h>
	#include <unistd.h>
	#define INVALID_SOCKET -1
	#define SOCKET_ERROR -1
	#define closesocket(s) close (s)
	typedef int SOCKET;
	typedef struct sockaddr_in SOCKADDR_IN;
	typedef struct sockaddr SOCKADDR;
#endif
	typedef struct hostent hostent;
	int init_sock(int port, char* dest, SOCKET* irc_sock);
	/*
	 * init_sock : create a new sock and initialize it for a new irc connection
	 * args :
	 * 	port		port to connect
	 * 	dest		addresse ipv6, ipv4 or Domane name to the irc server
	 * 	irc_sock	(out) sock to the irc connection
	 * return :
	 * 	0 if success
	 * 	another number descripted on the error.h if error
	 */
	int send_msg(SOCKET* sock, char* msg);
#endif
